﻿#ifndef CUSTOMZOOMCHART_H
#define CUSTOMZOOMCHART_H

#include <QObject>
#include <QtCharts/QChartView>
#include <QSplineSeries>
#include "tipnotify.h"
#include "configuredialog.h"
using namespace QtCharts;


class CustomZoomChart : public QChartView
{
public:
    Q_OBJECT
public:
    CustomZoomChart(QWidget* pParent = nullptr);
    ~CustomZoomChart();

protected:
    virtual void mouseMoveEvent(QMouseEvent *pEvent) override;
    virtual void mousePressEvent(QMouseEvent *pEvent) override;
    virtual void mouseReleaseEvent(QMouseEvent *pEvent) override;
    virtual void wheelEvent(QWheelEvent *pEvent) override;

    void attachAxis(int &themeType);
    void attachTipTool(QSplineSeries* series);

private:
    bool m_bMiddleButtonPressed;
    TipNotify *m_tipTool;
    QGraphicsSimpleTextItem *m_coordX;
    QGraphicsSimpleTextItem *m_coordY;
    QList<TipNotify *> m_tipTools;
    QPoint m_oPrePos;
    QList<QSplineSeries *> m_splinesSeriesGroup;
    QList<QAbstractAxis*> m_axesGroup;
    ConfigStruct m_chartConfig;

public:
    bool setChartView(QVector<QStringList>& originData);
    void removeSeries();
    void removeTips();

    void setChartConfig(const ConfigStruct &chartConfig);

public slots:
    void connectMarkers();
    void disconnectMarkers();
    void handleMarkerClicked();
    void keepCallout();
    void tooltip(QPointF point, bool state);

};

#endif // CUSTOMZOOMCHART_H
